package com.nave.segundaguerra.game;

import com.nave.segundaguerra.servidorecliente.util.BitmapStorage;
import com.nave.segundaguerra.servidorecliente.util.ImageLibrary;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
import android.util.Log;
import android.widget.RelativeLayout;

public class Lupa {
	Bitmap lupa;
	PointF posLupa;
	public Lupa(Point tamanhoTela){
		//this.lupa = ImageLibrary.getInstance().getImage("ZoomGeneral");
		this.lupa = BitmapStorage.getInstance().getLupa();
		//this.lupa = CalculoImagem.getInstance().RedimensionarImagem(this.lupa, (8 * tamanhoTela.y) / 100, (8 * tamanhoTela.x) / 100);
		this.posLupa = new PointF(tamanhoTela.x/ 1.1f, tamanhoTela.y / 7);
	}
	public void draw (Canvas canvas, RelativeLayout container){
		if(this.lupa != null){
		this.posLupa = new PointF((canvas.getWidth() / 1.1f) + container.getScrollX() , (canvas.getHeight() / 7) + container.getScrollY());
		canvas.drawBitmap(this.lupa, posLupa.x, posLupa.y, new Paint());
		}
	}
	public Bitmap getImage(){
		return this.lupa;
	}
	public PointF getPosition(){
		return this.posLupa;
	}
	public boolean Intersect(PointF posObject){
		if(posObject.x >= this.getPosition().x && posObject.x < (this.getPosition().x + this.getImage().getWidth()) && 
		posObject.y >= this.getPosition().y && posObject.y < (this.getPosition().y + this.getImage().getHeight())){
			Log.i("Lupa", "Acertou !!!");
		return true;
		}
		return false;
	}
}
